package com.heima.mapper;

import com.github.pagehelper.Page;
import com.heima.pojo.VmType;
import com.heima.pojo.dto.VmTypePageDto;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface VmTypeMapper {


    /**
     * 根据vmType查询type
     */
    @Select("select * from tb_vm_type")
    List<VmType> queryType();

    /**
     * 设备分页查询
     * @param dto
     * @return
     */
    Page<VmType> pageQuery(VmTypePageDto dto);

    /**
     * 新增设备
     * @param vmType
     */
    @Insert("insert into tb_vm_type(name ,model ,vm_row,vm_col,channel_max_capacity,image) " +
            "values(#{name},#{model},#{vmRow},#{vmCol},#{channelMaxCapacity},#{image})")
    void insert(VmType vmType);

    /**
     * 修改设备
     * @param vmType
     */
    @Update("update tb_vm_type set name = #{name},model = #{model},vm_row = #{vmRow},vm_col = #{vmCol}," +
            "channel_max_capacity = #{channelMaxCapacity} where type_id = #{typeId}")
    void update(VmType vmType);

    /**
     * 根据id删除设备
     * @param typeId
     */
    @Delete("delete from tb_vm_type where type_id = #{typeId}")
    void delById(Integer typeId);
}
